load_metadata_internal: don't leak GBytes
authorSimon McVittie <smcv@debian.org>
Sun, 30 Oct 2016 13:52:51 +0000 (13:52 +0000)
committerAtomic Bot <atomic-devel@projectatomic.io>
Sun, 30 Oct 2016 22:11:15 +0000 (22:11 +0000)
Found by valgrind memcheck. g_variant_new_from_bytes takes a ref to the
bytes, so we need to release the original ref.

Signed-off-by: Simon McVittie <smcv@debian.org>
Closes: #556
Approved by: cgwalters

src/libostree/ostree-repo.c

index 2e35faf836d9c1c65f99f40f6bef3397e8d9eba8..1f866bbe3d900b21eede024832a7f51586b33585 100644 (file)
@@ -2593,7 +2593,7 @@ load_metadata_internal (OstreeRepo       *self,
             }
           else
             {
-              GBytes *data = glnx_fd_readall_bytes (fd, cancellable, error);
+              g_autoptr(GBytes) data = glnx_fd_readall_bytes (fd, cancellable, error);
               if (!data)
                 goto out;
               ret_variant = g_variant_new_from_bytes (ostree_metadata_variant_type (objtype),